<?php 
	ob_start(); session_start(); 
	require_once('adminpanel/config/setting.php');
	if(!($_SESSION['memberid'])){
		header('Location: login-warning.php');		
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Questions</title>
</head>
<style>
	.topmenu{
		font-family:arial;
		font-size:14px;
		color:#FFFFFF;
		text-decoration:none;
	}
	.topmenu:hover{
		font-family:arial;
		font-size:14px;
		color:#FFFFFF;
		text-decoration:underline;
	}
</style>

<body style="margin:0px; background-color:#f1f1f1">
	<div id="header" style="background:url(images/top-bg.png) repeat-x; " align="center">
    	<div style="width:982px;" >
        	<div style="padding-top:30px; padding-right:20px; color:#FFFFFF" align="right">
            	<img src="images/the-century-logo.png" style="top:20px; margin-left:50px;" align="left" />
            	<a href="index.php" class="topmenu">Home</a> &nbsp; | &nbsp; 
                <a href="about-us.php" class="topmenu">About Us</a> &nbsp; | &nbsp; 
                <a href="questions.php" class="topmenu"><font size="5px">Questions</font></a> &nbsp; | &nbsp; 
                <a href="reservation.php" class="topmenu">Reservation</a> &nbsp; | &nbsp; 
				<a href="menu.php" class="topmenu">Menu</a> &nbsp; | &nbsp; <?php if(!($_SESSION['username'])){?>
                <a href="signup.php" class="topmenu">Signup</a><?php } else {?>
                <a href="logout.php" class="topmenu">Logout</a><?php }?>
                <br /><br />
                <?php 
                include('login.php');
				?>            
            </div>
        	<img src="images/top-gradient.png" />
            <div style="position:absolute; top:200px; margin-left:50px; font-size:24px; color:#F00 ">Questions</div>
        </div>
    </div>
	<div id="body" align="center">
    	<div style="width:982px" align="center">
            <div style="width:900px;margin-left:0px; line-height:18px; font-family:verdana; font-size:12px; color:#666" align="left" >
            <div style="width:900px; height:211px; background:url(images/ask.png) no-repeat"><br /><br />
            	<span style="color:#FFFFFF; font-size:16px; padding-left:35px"><b>Ask Your Questions here:</b></span><br /><br />
                <form name="qform" method="post" action="question-details.php" >                
                <div style="padding-left:35px;"><input name="asknow" style="height:34px; font-size:16px; border:solid 1px; width:828px" /></div><br />
                <div style="padding-left:35px; padding-right:35px" align="right">
                  <input name="askbtn" type="submit" value="Ask Now" onclick="return validateField();" style="height:40px; width:150px" />
                </div>
                </form>
            </div>
            <ol>
            
            <div style"width:500px ">
            <span style="color:000000; font-size:16px; font-family: verdana"><b>Recent Questions:</b></span><br /><br />
            </div>
			<?php 
            $result = mysql_query("SELECT * FROM tbl_question ") or die (mysql_error());
            while ($row = mysql_fetch_array($result)){
				$qid = $row['id'];
                $question = $row['question'];
				$answers = '';
				$aresult = mysql_query("SELECT * FROM tbl_answer where qid='$qid' ") or die (mysql_error());
				while ($arow = mysql_fetch_array($aresult)){
					$answers .= '<li style="color:#000000"><i><b>Answer:</b></i> '.$arow['answer'].'</li>';
				}
				echo '<li><b style="color:#F00">'.$question.'</b>
				<ul>'.$answers.'</ul>
				</li>';
            }	  
            ?>     
            <br /><br /><br />         
            </ol>

            </div>
        </div>
    </div>
    <div id="footer" style="background:url(images/btm-bg.png) repeat-x; height:166px" align="center">
    	<div style="width:982px">
        	<div style="height:40px"></div>
        	<img src="images/btm-gradient.png" />
        </div>
    		
    </div>
    <
<script>
	function validateField(){
		var emptyfield = '';
		
		if(document.qform.asknow.value.trim()==''){
			emptyfield += ' Your Question \n';
		}
		if(emptyfield==''){
			return true;				
		}else{
			alert('Please complete required fields: \n'+emptyfield);
			return false;
		}
	}

</script>    
</body>
</html>